﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.Master" AutoEventWireup="true"
    Inherits="Wjtour.Web.Admin.scene.addedi" %>

<%@ Register TagPrefix="CuteWebUI" Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" %>
<%@ Register TagPrefix="CE" Namespace="CuteEditor" Assembly="CuteEditor" %>
<%@ Import Namespace="Wjtour.Domain" %>
<%@ Import Namespace="Wjtour.Common" %>
<%@ Import Namespace="Wjtour.Domain.dto" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link rel="stylesheet" href="/css/bootstrap.css" type="text/css" />
    <script language="javascript" src="/js/bootstrap.min.js" type="text/javascript"></script>
    <style type="text/css">
        #myTab
        {
            margin-bottom: 0px;
        }

        ul, li, p
        {
            margin: 0px;
            padding: 0px;
        }

        .tab-pane
        {
            clear: both;
        }

            .tab-pane ul
            {
                margin: 0px;
                padding: 0px;
            }

                .tab-pane ul li
                {
                    float: left;
                    width: 160px;
                    height: 230px;
                    border: 3px solid #808080;
                    padding: 2px 2px 2px 2px;
                    margin: 5px 5px 5px 5px;
                    list-style: none;
                    background-color: #eef2fb;
                    text-align: center;
                }

            .tab-pane p
            {
                height: 23px;
                text-align: left;
                padding-left: 10px;
            }

            .tab-pane li img
            {
                border: 1px solid #efefef;
            }

            .tab-pane li span
            {
                display: block;
            }

        .nav-tabs
        {
            border-bottom: 1px solid #CECECE;
        }
        /** 分页 **/
        .pagecut
        {
            clear: both;
            margin: 10px 0 10px 0;
            color: #a0a0a0;
            text-align: center;
            line-height: 17px;
        }

            .pagecut span
            {
                padding-right: 12px;
                display: inline-block;
            }

            .pagecut .home
            {
                background: url(/css/images/firstpage.png) left 4px no-repeat;
                padding-left: 10px;
            }

            .pagecut .prepage
            {
                background: url(/css/images/prepage.png) left 4px no-repeat;
                padding-left: 10px;
            }

            .pagecut .nextpage
            {
                background: url(/css/images/nextpage.png) right 4px no-repeat;
                padding-right: 10px;
                padding-left: 12px;
            }

            .pagecut .endpage
            {
                background: url(/css/images/endpage.png) right 4px no-repeat;
                padding-right: 10px;
                padding-left: 12px;
            }

            .pagecut .pagenum
            {
                background: url(/css/images/pagebg.png) center top no-repeat;
                color: #444;
                width: 29px;
                height: 24px;
                padding: 5px 0 0 0;
            }

            .pagecut .thispage
            {
                background: url(/css/images/thispage.png) center top no-repeat;
                color: #FFF;
                width: 29px;
                height: 24px;
                padding: 5px 0 0 0;
            }

            .pagecut .pagecount
            {
                background: none;
            }

        .addnew_box
        {
            margin-top: 10px;
            margin-bottom: 2px;
            height: 26px;
            width: 100%;
            line-height: 26px;
        }

            .addnew_box input[type=button]
            {
                height: 26px;
            }

        .selected_box
        {
            margin-top: 10px;
            margin-bottom: 2px;
            width: 100%;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="content" runat="server">

    <div>
        <ul class="nav nav-tabs" id="myTab">
            <li class="active"><a href="#scenicwords" data-toggle="tab" data-index="0">景区基本信息</a></li>
            <li><a href="#scenicimg" data-toggle="tab" data-index="1">美图体验</a></li>
            <li><a href="#scenictraffic" data-toggle="tab" data-index="2">交通指南</a></li>
            <li><a href="#scenicfood" data-toggle="tab" data-index="3">附近餐饮</a></li>
            <li><a href="#scenichotel" data-toggle="tab" data-index="4">周边住宿</a></li>
        </ul>

    </div>

    <div class="tab-content">
        <!--tab1-->
        <div class="tab-pane active" id="scenicwords">
            <table id="addeditable" border="1" cellpadding="0" cellspacing="0" bordercolor="#dddddd">
                <tr>
                    <td align="right">景点名称：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="scenename" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景点logo：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="img" Width="300" />
                        <asp:FileUpload ID="upload" runat="server" />
                        <asp:Button ID="btnPublish" runat="server" Text="上传" />
                    </td>
                </tr>
                <tr>
                    <td align="right">图片预览：
                    </td>
                    <td>&nbsp;<asp:Image runat="server" ID="imgPreview" ImageUrl="" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景区地址：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="address" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景区等级：
                    </td>
                    <td>&nbsp;<asp:DropDownList runat="server" ID="scenerank">
                        <asp:ListItem Text="1A" Value="1" />
                        <asp:ListItem Text="2A" Value="2" />
                        <asp:ListItem Text="3A" Value="3" />
                        <asp:ListItem Text="4A" Value="4" />
                        <asp:ListItem Text="5A" Value="5" />
                    </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right">开放时间：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="opentime" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">联系电话：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="contactphone" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景区印象：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="sceneimpression" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景点网址：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="sceneweb" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">挂牌价：
                    </td>
                    <td>&nbsp;<asp:TextBox runat="server" ID="price" Width="300" />
                    </td>
                </tr>
                <tr>
                    <td align="right">景区分类：
                    </td>
                    <td>&nbsp;<asp:DropDownList runat="server" ID="scenetype">
                        <asp:ListItem Text="东太湖生态旅游度假区" Value="1" />
                        <asp:ListItem Text="水乡古镇休闲旅游区" Value="2" />
                        <asp:ListItem Text="丝绸商贸文化旅游区" Value="3" />
                    </asp:DropDownList>
                    </td>
                </tr>
                <tr>
                    <td align="right">是否推荐：
                    </td>
                    <td>&nbsp;<asp:CheckBox ID="isrecommend" runat="server" />推荐
                    </td>
                </tr>

                <tr>
                    <td align="right">景区介绍：<br />
                        <br />
                        <span style="color: red; font-weight: bold;">F12放大和<br />
                            缩小编辑框</span>
                    </td>
                    <td>&nbsp;
                <ce:editor id="introduce" runat="server" height="860" width="790" />
                    </td>
                </tr>
                <tr>
                    <td align="right">&nbsp;
                    </td>
                    <td>&nbsp;<asp:Button ID="submit" runat="server" Text=" 保 存 " />
                    </td>
                </tr>
            </table>
        </div>

        <!--tab2-->
        <div class="tab-pane" id="scenicimg">
            <div class="addnew_box">
                上传图库图片：<CuteWebUI:Uploader ID="Uploader1" runat="server" InsertButtonID="button1" MultipleFilesUpload="true">
                </CuteWebUI:Uploader>
                <asp:Button ID="button1" runat="server" Text="添加图片" />
            </div>
            <div class="selected_box">
                <ul>
                </ul>

                <!-- 分页 -->
                <div class="pagecut">
                </div>
            </div>
        </div>
        <!--tab3-->
        <div class="tab-pane" id="scenictraffic">
            <table id="Table1" border="1" cellpadding="0" cellspacing="0" bordercolor="#dddddd">
                <tr>
                    <td align="right">交通指南：
                    </td>
                    <td>&nbsp;
                        <ce:editor id="trafficguide" runat="server" height="560" width="790" />
                    </td>
                </tr>
                <tr>
                    <td align="right">&nbsp;
                    </td>
                    <td>&nbsp;<asp:Button ID="submit2" runat="server" Text=" 保 存 " />
                    </td>
                </tr>
            </table>
        </div>
        <!--tab4-->
        <div class="tab-pane" id="scenicfood">
            <div class="addnew_box">
                搜索餐饮：
                <input type="text" id="searachrest" />
                <input type="hidden" id="hide_rest_id" />
                <input type="button" value="添加" id="restadd" />
            </div>
            <div class="selected_box">
                <ul>
                </ul>

                <!-- 分页 -->
                <div class="pagecut">
                </div>
            </div>
        </div>
        <!--tab5-->
        <div class="tab-pane" id="scenichotel">
            <div class="addnew_box">
                搜索住宿：
                <input type="text" id="searachhotel" />
                <input type="hidden" id="hide_hotel_id" />
                <input type="button" value="添加" id="hoteladd" />
            </div>
            <div class="selected_box">
                <ul>
                </ul>

                <!-- 分页 -->
                <div class="pagecut">
                </div>
            </div>
        </div>

    </div>

    <script language="javascript">
        var sceneid = <%=id%>;

        function removepic(picid) {
            $.ajax({
                url: '/admin/ajax/PictureHandler.ashx',
                data: { 'type': 'removepic', 'picid': picid,'sceneid':sceneid },
                dataType: 'json',
                success: function (d) {
                    if (d.Errcode != "0") {
                        alert(d.Errmsg);
                    } else {
                        window.location.reload();
                    }
                },
                error: function () {

                }
            });
        }

        $(document).ready(function () {
            $("#restadd").click(function(){
                $.ajax({
                    url: '/admin/ajax/AddSceneResturantHandler.ashx',
                    data: { 'sceneid': sceneid, 'restid': $("#hide_rest_id").val()},
                    dataType: 'json',
                    success: function (d) {
                        if (d.Errcode != "0") {
                            alert(d.Errmsg);
                        } else {
                            $("#searachrest").val('');
                            $("#hide_rest_id").val('');
                            calldata('/sceneresturant.ashx', 1, 3);
                        }
                    },
                    error: function () {

                    }
                });
            });

            $("#hoteladd").click(function(){
                $.ajax({
                    url: '/admin/ajax/AddSceneHotelHandler.ashx',
                    data: { 'sceneid': sceneid, 'hotelid': $("#hide_hotel_id").val()},
                    dataType: 'json',
                    success: function (d) {
                        if (d.Errcode != "0") {
                            alert(d.Errmsg);
                        } else {
                            $("#searachhotel").val('');
                            $("#hide_hotel_id").val('');
                            calldata('/scenehotel.ashx', 1, 4);
                        }
                    },
                    error: function () {

                    }
                });
            });

            $('#myTab a:first').tab('show');
            $('#myTab a').click(function (e) {
                e.preventDefault();
                $(this).tab('show');
                var index = parseInt($(this).data("index"));
                switch (index) {
                    case 1:
                        if(sceneid==0){
                            alert("请先保存景区基本信息后，才能添加此项！");
                            return;
                        }
                        calldata('/scenepicture.ashx', 1, 1);
                        break;
                    case 3:
                        if(sceneid==0){
                            alert("请先保存景区基本信息后，才能添加此项！");
                            return;
                        }
                        calldata('/sceneresturant.ashx', 1, 3);
                        break;
                    case 4:
                        if(sceneid==0){
                            alert("请先保存景区基本信息后，才能添加此项！");
                            return;
                        }
                        calldata('/scenehotel.ashx', 1, 4);
                        break;
                    default:
                        break;
                }
            });
        });

        function calldata(url, page, type) {
            $.ajax({
                url: url,
                data: { 'page': page, 'sceneid': '<%=id%>' },
                dataType: 'json',
                success: function (d) {
                    if (type == 1) {
                        $("#scenicimg ul").empty();
                    }

                    if (type == 3) {
                        $("#scenicfood ul").empty();
                    }

                    if (type == 4) {
                        $("#scenichotel ul").empty();
                    }

                    for (var i = 0; i < d.Datas.length; i++) {
                        var p = d.Datas[i];
                        if (type == 1) {
                            var html = "";
                            html += "<li style='height:160px;'>";
                            html += "<div>";
                            html += "<span><img src=\"" + p.smallImg + "\" style=\"width: 138px;height: 99px;\"/></span>";
                            html += "</div>";
                            html += p.picturetitle;
                            html += "<span><input type='button' value='删除' id='del_picture_"+p.id+"' onclick='dellink()'/></span></li>";
                            $("#scenicimg ul").append(html);

                        }
                        if (type == 3) {
                            var html = "";
                            html += "<li>";
                            html += "<a href=\"restdetail.aspx?id=" + p.id + "\" target=\"_blank\"><img src=\"" + p.img + "\" style=\"width: 138px;height: 99px;\"/></a>";
                            html += "<div>";
                            html += "	<h4><a href=\"restdetail.aspx?id=" + p.id + "\" target=\"_blank\">" + p.resturantname + "</a></h4>";
                            html += "	<span>人均消费：" + p.averagecosume + "元</span>";
                            html += "	<span>地址：" + p.address + "</span>";
                            html += "	<span>电话：" + p.contactphone + "</span>";
                            html += "   <span><input type='button' value='删除' id='del_resturant_"+p.id+"' onclick='dellink()'/></span>";
                            html += "</div>";
                            html += "</li>";
                            $("#scenicfood ul").append(html);

                        }
                        if (type == 4) {
                            var html = "";
                            html += "<li>";
                            html += "<a href=\"travelhoteldetail.aspx?id=" + p.id + "\" target=\"_blank\"><img src=\"" + p.img + "\" style=\"width: 138px;height: 99px;\"/></a>";
                            html += "<div>";
                            html += "	<h4><a href=\"travelhoteldetail.aspx?id=" + p.id + "\" target=\"_blank\">" + p.hotelname + "</a></h4>";
                            html += "	<span>酒店等级：五星级酒店</span>";
                            html += "	<span>地址：" + p.address + "</span>";
                            html += "	<span>电话：" + p.reservephone + "</span>";
                            html += "   <span><input type='button' value='删除' id='del_hotel_"+p.id+"' onclick='dellink()'/></span>";
                            html += "</div>";
                            html += "</li>";
                            $("#scenichotel ul").append(html);
                        }
                    }

                    if (type == 1) {
                        $("#scenicimg .pagecut").empty();
                        $("#scenicimg .pagecut").html(d.PagnationHtml);
                        $("#scenicimg .pagecut a").click(function (e) {
                            e.preventDefault();
                            var path = $(this).data("url");
                            var page = path.split('=')[path.split('=').length - 1];
                            calldata(url, page, 1);
                        });
                    }
                    if (type == 3) {
                        $("#scenicfood .pagecut").empty();
                        $("#scenicfood .pagecut").html(d.PagnationHtml);
                        $("#scenicfood .pagecut a").click(function (e) {
                            e.preventDefault();
                            var path = $(this).data("url");
                            var page = path.split('=')[path.split('=').length - 1];
                            calldata(url, page, 3);
                        });
                    }
                    if (type == 4) {
                        $("#scenichotel .pagecut").empty();
                        $("#scenichotel .pagecut").html(d.PagnationHtml);
                        $("#scenichotel .pagecut a").click(function (e) {
                            e.preventDefault();
                            var path = $(this).data("url");
                            var page = path.split('=')[path.split('=').length - 1];
                            calldata(url, page, 4);
                        });
                    }

                }
            });
        }

        function dellink()
        {
            var el = event.srcElement|| event.target;
            var typestr = $(el).attr("id").split('_')[1];
            var id = $(el).attr("id").split('_')[2];
            var path = "";
            var type = 1;
            if(typestr=="picture"){
                path = "/admin/ajax/DelScenePictureHandler.ashx";
                type = 1;
            }
            if(typestr=="resturant"){
                path = "/admin/Ajax/DelSceneResturantHandler.ashx";
                type = 3;
            }
            if(typestr=="hotel"){
                path = "/admin/ajax/DelSceneHotelHandler.ashx";
                type = 4;
            }

            $.ajax({
                url: path,
                data: { 'sceneid': sceneid, 'id': id},
                dataType: 'json',
                success: function (d) {
                    if (d.Errcode != "0") {
                        alert(d.Errmsg);
                    } else {
                        alert(d.Errmsg);
                        switch (type) {
                            case 1:
                                calldata('/scenepicture.ashx', 1, 1);
                                break;
                            case 3:
                                calldata('/sceneresturant.ashx', 1, 3);
                                break;
                            case 4:
                                calldata('/scenehotel.ashx', 1, 4);
                                break;
                            default:
                                break;
                        }
                    }
                },
                error: function () {

                }
            });
        }

        $(function () {
            $("#searachrest").autocomplete({
                source: "/admin/Ajax/GetResturantHandler.ashx",
                focus: function (event, ui) {
                    $("#searachrest").val(ui.item.label);
                    return false;
                },
                select: function (event, ui) {
                    $("#searachrest").val(ui.item.label);
                    $('#hide_rest_id').val(ui.item.value);
                    return false;
                }
            }).data("autocomplete")._renderItem = function (ul, item) {
                if (item.label.indexOf($("#searachrest").val()) > -1
                    || $("#searachrest").val().trim() == '') {
                    return $("<li></li>")
                        .data("item.autocomplete", item)
                        .append($("<a></a>").text(item.label))
                        .appendTo(ul);
                }
            };
        });

        $(function () {
            $("#searachhotel").autocomplete({
                source: "/admin/Ajax/GetHotelHandler.ashx",
                focus: function (event, ui) {
                    $("#searachhotel").val(ui.item.label);
                    return false;
                },
                select: function (event, ui) {
                    $("#searachhotel").val(ui.item.label);
                    $('#hide_hotel_id').val(ui.item.value);
                    return false;
                }
            }).data("autocomplete")._renderItem = function (ul, item) {
                if (item.label.indexOf($("#searachhotel").val()) > -1
                    || $("#searachhotel").val().trim() == '') {
                    return $("<li></li>")
                        .data("item.autocomplete", item)
                        .append($("<a></a>").text(item.label))
                        .appendTo(ul);
                }
            };
        });
    </script>
</asp:Content>
